import React, { Component,Suspense } from 'react'
import {Route,HashRouter as Router,Switch, Redirect} from 'react-router-dom'
import routes from './routes'
export default class Index extends Component {
    render() {
        return (
            <Suspense fallback={<div>Loading....</div>}>
                <Router>
                    <Switch>
                    {
                        routes.map(route=>{
                            return <Route 
                            exact={route.exact}
                            path={route.path}
                            key={route.path}
                            render={(props)=>{
                                return <route.component {...props} routes={route.routes}></route.component>
                            }}
                            ></Route>
                        })
                    }  
                    <Redirect to='/404'></Redirect>
                    </Switch>
                </Router>
            </Suspense>
        )
    }
}
